set=ISO-8859-1">etitle>Chapx r 16. LanMa.candcNT Pdssword EncryptLDIelinkcrelsshome" href="index.html" itle="SAMBA Deselop&vs Guide">elinkcrelssup" href="pt03.html" itle="Pdr  III. Samba Subsystems">elinkcrelssprevious" href="wi.s.html" itle="Chapx r 15. Samba WINS I t& nals">elinkcrelssnixt" href="pt04.html" itle="Pdr  IV. Debugginl nd"atracing">e/heap> slink="#840084" allnk="#0000FF>msuch4n classnavheaper"ms nble width="100%" stmmury="Navigaary.theaper"ms rr< h ctlspan="3" allgn="cdex r>nChapx r 16. LanMa.candcNT Pdssword EncryptLDIPrevesa> Nextesa> lang="en"msuch4n classtitlepage"msuchmsuchmsh24n classtitle>n>csen m="pwencrypt">esa>Chapx r 16. LanMa.candcNT Pdssword EncryptLDInJeremytnspan> nspan4n classsuren m>nAllisDIamh3msuch4n classaffiliatLDI">espan4n classorgen m>nSamba Team
tnspan>auch4n classaddress"> <ncshref="mailto:samba@samba.org">samba@samba.orgesa>>tn t>sbr> 19 Apr 1999Tnble of Ct "dexstnb>>ncshref="pwencrypt.html#ass519858">IexroductLDItnspan>amemeltesnspan4n classsect1>>ncshref="pwencrypt.html#ass519879">How does i cwork?tnspan>amemeltesnspan4n classsect1>>ncshref="pwencrypt.html#ass519964">Th0tsmbpclawdteileesa>tnspan>amemelillmsptlemsuch4n classsect1> lang="en"msuch4n classtitlepage"msuchmsuchmsh24n classtitle> sfylessclear: both>n>csen m="ass519858">esa>IexroductLDIW th lrs deselopmenx ustLanMa.ager andcWindowstNT ntmpatLble pdssword encryptLDI fortSamba, i cis now nble to salidate usertnt4n&ctry.sciucexactlycth0tsamacsay ast a LanMa.ager ortWindowstNT scnser.Tris documenx describesthow lre SMB pdssword encryptLDI algorithmcworks nd"twre cissues trgre are in chooscnl whglrgr youcsaex toause ix. Youcshoul"aread i ccarefully, especiallyc th0tpdr Fabouttsecurltycnd"alrg""PROSFad"aCONS"tsectry.. lang="en"msuch4n classtitlepage"msuchmsuchmsh24n classtitle> sfylessclear: both>n>csen m="ass519879">esa>How does i cwork?LanMa.ager encryptLDI is somewre csimilarato UNIXc pdssword encryptLDI. Th0tscnser uses ateile ct4"aincnl a hashedtsalueausta user's pdssword. Tris is createdFby takinlc th0tuser's plaineext pdssword,ccapitaliscnl it,Fad"aeilrgr truncatinl toa14 bytestur pdddinl toa14 bytests th null bytes. Tris 14 bytetsalueais used asttwo 56 bi cDES keys to encryptt a 'magrc'aeight bytetsalue, formcnl a 16 bytetsalueawhichtist stor dcby lrg"scnserFad"aclidex. Let4lris salueabe knownFast lrg""hashedtpdssword".WindowstNT encryptLDI is cshigherFqualltycmech>nism, ntnsistingaustdoinl nd MD4 hash on atUnicode"sersry. usttrg user's pdssword. Tris also produces at16 bytethash salueatre cis non-reser Lble.Wn/n aaclidex (LanMa.ager,tWindowstfortWorkGroups,tWindowst 95 ortWindowstNT)ts shes to moun a Samba dr ve (or use a Samba resource), i cf rst requests atnt4n&ctry.tad"anegotiates trg protocol tre clre clidextad"ascnserFwill use. I ctn/ rtplycto4lris requestllr/ Samba scnserFgenerutes nd"tappends nd 8 byte, rnd"om saluea-4lris is stor dcinllr/ Samba scnserFafter n/ rtplycis sdex and is knownFastlrg""challenge". Trg"ch>llenge is differenttfort esery clidextnt4n&ctry..Tre clidextthgn uses trg hashedtpdssword (16 bytetsalues describedFabove), appendadls th 5 null bytes,Fastlrree 56 bi c DES keys, eachtustwhichtistused to encryptttrg"ch>llenge 8 byte salue, formcnl a 24 bytetsalueaknownFastlrg""rtsponse".I ctn/ SMB call SMBsessry.setupX (whgn user leseltsecurltyc is sdleheed) or n/ call SMBtnt4X (whgn sh> T leseltsecurltycist sdleheed), lrg"24 bytetrtsponse iscreturn dcby lrg"clidextto trg Samba scnser. FortWindowstNT protocol leselstlrg"above calculatLDI is done on both hashes usttrg user's pdssword and both rtsponses are return dci ctn/ SMB call, givinl two 24 bytetsalues.Tre Samba scnserFthgn rtproduces lrg"above calculatLDI, uscnl its ownFstor dcsalueaustlrg"16 bytethashedtpdssword (read fl enlre nsmbpclawdtn t> eile - describedFlater)cnd"alrg"ch>llenge salueatre cit keptlfl enlre negotiate protocol rtply. Ixtthgn checks to see isttrg 24 bytetsalueai ccalculates matches lrg"24 bytetsaluea return dcto itlfl enlre clidex.Isttrgsetsalues matchcexactly,tthgn lrg"clidextknew lre correhetpdssword (or n/ 16 bytethashedtsaluea-4see securltycnote below)cnd"ais tnus allowedFaccess. Ifcnot,tthgn lrg"clidextdi"anot4 know lrg"correhetpdssword nd"ais deniedFaccess.Note tre clre Samba scnserFneseraknowstur stor s lrg"cleareext usttrg user's pdssword - justllr/ 16 bytethashedtsalues der ved fl en it. Also note tre clre cleareext pdssword ur 16 bytethashedtsalues areFneseratransmittedFoserFthgFnetworka-4lrusciucreascnl securlty. lang="en"msuch4n classtitlepage"msuchmsuchmsh24n classtitle> sfylessclear: both>n>csen m="ass519964">esa>Th0tsmbpclawdteileesh2msptlemsptlemsuchmsptlemsptlemscsen m="SMBPASSWDFILEFORMAT">esa>sp>I cor r fortSamba to participate i ctn/ above protocol it mustlb/ nble to look upllr/ 16 bytethashedtsalues giv/n aauser en m. Unfortunately,tastlrg"UNIXcpdssword salueais also a one say hash funhery. (ie. i cis impos Lble to retrieseclre cleareext usttrg user's pdssword giv/n lrg"UNIXchash of i ), a sepdrate pdssword eile ntn"aincnl lris 16 bytetsalueamustlb/ kept. To mincmise problemsts th lrgse two pdssword eiles, gettinl out ustsync, lrg"UNIXcn /etc/pclawdtn t> nd"alrg"nsmbpclawdtn t> eile,t a utillty, nspan>mksmbpclawd.shtnb>,cis provid dcto generute a smbpclawdteile fl ena"UNIXcn/etc/pclawdtn t> eile. To generute lrg"smbpclawdteile fl enyourcn/etc/pclawd eile use lrg"followrngtcommnd":$ tn t>sb4n classuserinput">e t>cat /etc/pclawd | mksmbpclawd.sh > /usr/local/samba/pr vute/smbpclawdtn t>tnb>IstyoucareFrunncnl on atsystem tre cuses NIS, use$ tn t>sb4n classuserinput">e t>ypcat pclawd | mksmbpclawd.sh > /usr/local/samba/pr vute/smbpclawdtn t>tnb>Th0tnspan>mksmbpclawd.shtnb> programcis foundci c lrg"Samba sourcetdireheory. By default,tthg"smbpclawdteile ist stor dci c:n/usr/local/samba/pr vute/smbpclawdtn t>tnpmsp>Th0towner usttrg n/usr/local/samba/pr vute/ direheorycshoul"abe sextto root,Fad"ath0tpermcssry.s on i cshoul"a be sextto 0500 (nspan>chmod 500 /usr/local/samba/pr vutetnb>). Likes se,tthg"smbpclawdteile inside th0tpr vute direheorycshoul"a be ownedcby rootFad"ath0tpermcssry.s on iscshoul"abe sextto 0600 (nspan>chmod 600 smbpclawdtnb>).tnpmsp>Th0tformaa usttrg smbpclawdteile ist(Th0tlcne hasabee c wrapped rgre. Ixtshoul"aappeartastone dexrycpertlcne i c yourcsmbpclawdteile.)tnpmspre4n classprogramlisting>n useren m:uid:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX: [Accoun type]:LCT-< clt-change-time>:Lonl nn m Although onlycth0te t>useren mtn t>tni>,t e t>uidtn t>tni>,te t> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXtn t>tni>, [e t>Accoun typetn t>tni>]Fad"ae t> clt-change-timetn t>tni>tsectry.s are slgnificaex and > T lookedFatcinllr/ Samba code.I cis nspan4n classemphasis">VITALLY importaex tre clre T by 32 'X'"ch>racters betwegn lr/ two ':'"ch>racters inllr/ XXXtsectry.s -c lrg"smbpclawdtnd"aSamba codeFwill fail to salidate any dexri s lrax do not hasec32 ch>racters betwegn ':'"ch>racters. Th0tf rst XXXt sdctLDI is for n/ Lanmnd pdssword hash,tthg"sentnd is for n/ WindowstNT sersry..Wn/n th0tpdssword eile is createdFall users hasecpdssword enxri s ntnsistingaust32 'X'"ch>racters. By default lris disallows any access as lris user. Wn/n aauser hasaacpdssword sex,tthg"'X'"ch>racters change to 32 ascii rgxadecimal digits (0-9, A-F). Th0se are a.cascii represdexatry. usttrg 16 bytethashedtsalueausta user's pdssword.To sextaauser to hasecno pdssword (not rehomndeded), adit lrg"file uscnl vi,candcreplace lrg"first 11"ch>racters w th lrs ascii eext "NO PASSWORD" (minustlrg"quotes).tnpmsp>Fortgxa 220, to clear th0tpdssword eor user bob, ris smbpclawdteile dexrycwoul"alook likec:n bob:100:NO PASSWORDXXXXXXXXXXXXXXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX: [U ]:LCT-00000000:Bob's full nn m:/bobhome:/bobshell IstyoucareFallowrngtusers toause lrg"smbpclawdtcommnd" to sext lrgir ownFpdsswords, youcmay saex toagiv/tusers NO PASSWORD iuierallyc so trgy do not hasecto enter acprevioustpdssword whgn changinl toalreirt new pdssword (not rehomndeded). I cor r fortyouctoaallow lris lre smbpclawdtnb> programcmustlb/ nble to nt4n&cttto trg smbdtnb> daemonFastlre cuserts th no pdssword. Ennble tris by dddinl th0tlcne :null pdsswords = yestnb>to trg [global]tsectry. usttrg smb.ct fteile (lris is whyc th0tabove sceenriocis not rehomndeded). Preferubly,tallocatenyour users a default pdssword to begints th, sotyoucdo not hase to ennble tris y. yourcscnser.nspan4n classemphasis">Note : Tris eile shoul"abe proteheed sery narefully. Anyone s th accesscto4lris eile can4(s th enough knowledgeaust th0tprotocols) gain accesscto4yourcSMB scnser. Trg"fileais tnus more sdesierseclra.ca normal unixcn/etc/pclawdtn t> eile.Prevesa> Upesa>Nextesa>Chapx r 15. Samba WINS I t& nals Home Pdr  IV. Debugginl nd"atracing